package com.foucus.myfouces.Base;

import android.util.Log;

import com.foucus.myfouces.Resource.Util.Rsa;


/**
 * Created by hong on 2016/12/23.
 * <p>
 */
public class BaseReq {

    private String variable_name = "";//变量名
    private String TAG = "BaseReq==";
    private int flag = 0;
    private String secret;
    StringBuilder stringBufferValue = new StringBuilder("");

    public void setValue(String name, String value) {
        if (value.length() == 0) {
            return;
        }
        flag++;
        if (flag == 1) {
            stringBufferValue.append(name);
            stringBufferValue.append("=");
            stringBufferValue.append(value);
        }
        if (flag != 1) {//两个以上的参数的情况
            stringBufferValue.append("&");
            stringBufferValue.append(name);
            stringBufferValue.append("=");
            stringBufferValue.append(value);
        }

    }

    public String getSecret(String meathod) {
        try {
            String source = stringBufferValue.toString();
            Log.i("ssss", meathod + "==加密字符串==>" + source);
            Rsa rsa = new Rsa();
            secret = rsa.encryptByPublic(source);
            Log.d("url", meathod + "==加密字符串==>" + secret.trim());
        } catch (Exception e) {
            e.printStackTrace();
        }
        return secret;
    }


}
